#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from bayesNetworkAlgo import bayes

listOPosts, listClasses = bayes.loadDataSet()
myVocabList =bayes.createVocabList(listOPosts)

print (myVocabList)

out = bayes.setOfWords2Vec(myVocabList,listOPosts[0])

print (out)

###4-2 词向量计算概率
print ('----------------4-2---------------')
trainMat = []

for postinDoc in listOPosts:
    trainMat.append(bayes.setOfWords2Vec(myVocabList, postinDoc))

p0V, p1V, pAb = bayes.trainNB0(trainMat, listClasses)
print (p0V)
print (p1V)
print (pAb)


#### 4-3 朴素bayes分类函数
bayes.testingNB()


####4.6 使用NBC过滤垃圾邮件
###4-5 文本解析及测试函数
bayes.spamTest()